package com.hzeport.bgs22emduty.inbound.job;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.hzeport.bgs22emduty.xxljob.GetFileXxlJob;
import com.hzeport.bgs22emduty.xxljob.HbXxJob;
import com.hzeport.bgs22emduty.xxljob.SampleXxlJob;
import com.hzeport.bgs22emduty.xxljob.SubsidyXxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class TaskSchedules {

    private final HbXxJob hbXxJob;
    private final SampleXxlJob sampleXxlJob;
    private final SubsidyXxlJob subsidyXxlJob;
    private final GetFileXxlJob getFileXxlJob;

    @Scheduled(cron = "${system-config.job-cron.getHBData}")
    public void getHBData() {
        log.info("[Schedule: getHBData] 拉取hb数据 开始执行");
        hbXxJob.getHBData(StringUtils.EMPTY);
        log.info("[Schedule: getHBData] 拉取hb数据 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.HB2012}")
    public void HB2012() {
        log.info("[Schedule: HB2012] hb2012数据拉取 开始执行");
        hbXxJob.HB2012(StringUtils.EMPTY);
        log.info("[Schedule: HB2012] hb2012数据拉取 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.getUserInfo}")
    public void getUserInfo() {
        log.info("[Schedule: getUserInfo] 全部值班人员获取 开始执行");
        sampleXxlJob.getUserInfo(StringUtils.EMPTY);
        log.info("[Schedule: getUserInfo] 全部值班人员获取 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.getPhone}")
    public void getPhone() {
        log.info("[Schedule: getPhone] 通讯录拉取 开始执行");
        sampleXxlJob.getPhone(StringUtils.EMPTY);
        log.info("[Schedule: getPhone] 通讯录拉取 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.messageSend}")
    public void messageSend() {
        log.info("[Schedule: messageSend] 短信发送功能 开始执行");
        sampleXxlJob.messageSend(StringUtils.EMPTY);
        log.info("[Schedule: messageSend] 短信发送功能 结束执行");
    }

//    @Scheduled(cron = "${system-config.job-cron.getEmergencyPlan}")
    public void getEmergencyPlan() {
        log.info("[Schedule: getEmergencyPlan]  开始执行");
//        sampleXxlJob.getEmergencyPlan(StringUtils.EMPTY);
    }

    @Scheduled(cron = "${system-config.job-cron.createSignForTempPerson}")
    public void createSignForTempPerson() {
        log.info("[Schedule: createSignForTempPerson] 签到信息入库 开始执行");
        sampleXxlJob.createSignForTempPerson(StringUtils.EMPTY);
        log.info("[Schedule: createSignForTempPerson] 签到信息入库 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.warnMapTask}")
    public void warnMapTask() {
        log.info("[Schedule: warnMapTask] 消息面向模块 开始执行");
        sampleXxlJob.warnMapTask(StringUtils.EMPTY);
        log.info("[Schedule: warnMapTask] 消息面向模块 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.getScheduleInfo}")
    public void getScheduleInfo() {
        log.info("[Schedule: getScheduleInfo] 大屏值班人员获取 开始执行");
        sampleXxlJob.getScheduleInfo(StringUtils.EMPTY);
        log.info("[Schedule: getScheduleInfo] 大屏值班人员获取 结束执行");
    }

    //20250929新增接口拉取附件
    @Scheduled(cron = "${system-config.job-cron.getFile}")
    public void getFileXxlJob() throws JsonProcessingException {
        log.info("[Schedule: getFileXxlJob] 获取群组任务 开始执行");
        getFileXxlJob.getFileXxlJob(StringUtils.EMPTY);
        log.info("[Schedule: getFileXxlJob] 获取群组任务 结束执行");
    }

    @Scheduled(cron = "${system-config.job-cron.getGroupInfo}")
    public void getGroupInfo() {
        log.info("[Schedule: getGroupInfo] 获取群组任务 开始执行");
        sampleXxlJob.getGroupInfo(StringUtils.EMPTY);
        log.info("[Schedule: getGroupInfo] 获取群组任务 结束执行");
    }

//    @Scheduled(cron = "${system-config.job-cron.getDutyPersonSubsidyStatus}")
    public void getDutyPersonSubsidyStatus() {
        log.info("[Schedule: getDutyPersonSubsidyStatus]  开始执行");
//        subsidyXxlJob.getDutyPersonSubsidyStatus(StringUtils.EMPTY);
    }


}
